class_name PlayerDownState
extends State


func _init() -> void:
	super("down")


func _on_setup() -> void:
	add_component(AnimationStateComponent.new("player_animation", owner.animator, "down"))
	add_component(TagStateComponent.new("player_tags", [GameplayTagLibrary.State_Air_Down]))


func _on_update(delta: float) -> void:
		var jump_height: float = owner.attribute_manager.get_attribute("jump_height").current_value
		var jump_time_to_peak: float = owner.attribute_manager.get_attribute("jump_time_to_descent").current_value
		var jump_gravity := ((2.0 * jump_height) / (jump_time_to_peak * jump_time_to_peak))
		owner.velocity.y += jump_gravity * delta
	
